<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateUserFirstLoginTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_first_login', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('userId')->default(0)->comment('用户id');
            $table->unsignedTinyInteger('type')->default(0)->comment('端 App\Kuafu\User\Enum\UserCodeEnum 1web 2pos 3applet 4merchant');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');

            $table->index(['userId', 'type'], 'idx_user');
            $table->index('createdAt', 'idx_created_at');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '用户首次登录记录';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_first_login');
    }
}
